/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bhatni.taskmanager.schedule;

import java.util.Date;
import org.quartz.CronTrigger;
import static org.quartz.CronScheduleBuilder.*;
import org.quartz.spi.MutableTrigger;


/**
 *
 * @author virendra
 */
public class CronSchedule extends ScheduleBase {

    private String cronExpression;
    private MutableTrigger trigger;

    @Override
    public Date getNextSchedule() {
        return trigger.getFireTimeAfter(this.lastScheduleTime);
    }

    /**
     * @return the cronExpression
     */
    public String getCronExpression() {
        return cronExpression;
    }

    /**
     * @param cronExpression the cronExpression to set
     */
    public void setCronExpression(String cronExpression) {
        this.cronExpression = cronExpression;

        trigger = cronSchedule(cronExpression).build();
  
    }
}
